use anyhow::Result;
use tide::log::LevelFilter;
use tide::{Body, Request, Response, StatusCode};

#[async_std::main]
async fn main() -> Result<()> {
    tide::log::with_level(LevelFilter::Debug);
    let mut app = tide::new();
    app.at("/").get(index);
    app.at("/*").serve_dir(".")?;
    app.listen("0.0.0.0:8080").await?;

    Ok(())
}

async fn index(_: Request<()>) -> tide::Result<Response> {
    let mut res = Response::new(StatusCode::Ok);
    res.set_body(Body::from_file("index.html").await?);
    Ok(res)
}
